/*
 * Copyright 2025 The JA-SIG Collaborative. All rights reserved.
 * distributed with this file and available online at
 */
package com.lap.auth.adapter.driving.persistence.organization;

import com.lap.auth.adapter.driving.persistence.organization.po.OrganizationPo;
import com.lap.auth.domain.organization.Organization;
import com.lap.auth.domain.organization.valueobject.Status;
import com.lap.framework.common.tool.EnumUtil;
import java.util.List;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(componentModel = "spring")
public interface OrgConverter {

  @Mapping(target = "event", ignore = true)
  Organization toDomain(OrganizationPo organizationPo);

  List<Organization> toDomains(List<OrganizationPo> list);

  OrganizationPo toPo(Organization organization);

  List<OrganizationPo> toPoList(List<Organization> list);

  default Status codeToStatus(Integer code) {
    return EnumUtil.fromCode(Status.class, code);
  }

  default Integer statusToCode(Status status) {
    return status.getCode();
  }
}
